package core;
import picocli.CommandLine.*;
import repository.Repository;

import java.io.File;
import java.io.IOException;
import java.nio.file.Path;

@Command(
        name = "rm"
)
/**
 * 实现了jit rm命令，形式为jit add -文件名
 */
public class JitRemove implements Runnable{
    @Parameters(paramLabel = "<remove-files>")
    private Path path;


    @Override
    public void run(){
        Repository repository = Repository.getInstance();
        try {
            path = repository.getWorkTree().relativize(path.toAbsolutePath());
            var index = repository.getIndex();
            index.remove(path);
            index.write();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
